﻿using System;
using System.Windows.Forms;
using SteroMood;

namespace SteroClood
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void ButtLoginStep1Click(object sender, EventArgs e)
        {
            if (!StereoMoodClient.AuthenticatePhaseOne())
            {
                MessageBox.Show("Step 1 failed: " + StereoMoodClient.LastError);
            }
            tbPin.Enabled = true;
            buttLoginStep2.Enabled = true;
        }

        private void ButtLoginStep2Click(object sender, EventArgs e)
        {
            if (!StereoMoodClient.AuthenticatePhaseTwo(tbPin.Text))
            {
                MessageBox.Show("Step 2 failed: " + StereoMoodClient.LastError);
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;  
        }

        private void LoginFormClosed(object sender, FormClosedEventArgs e)
        {
            if (this.DialogResult != DialogResult.OK)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;    
            }
        }
    }
}
